#include "DynamicArray.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

struct Student
{
    int id;
    char Name[20];
};

typedef struct Student Stu;
//指针函数：在堆上，返回值是指针
//指向函数的指针叫函数指针
Stu* CreateStu(int id,const char *name)
{
    Stu *s = (Stu*)malloc(sizeof(Stu));//
    if(s == NULL)
    {
        printf("malloc error!\n");
        return NULL;
    }
    s->id = id;
    strcpy(s->Name,name);
    return s;
}

int main()
{
    DArray a;
    InitDArray(&a);
    //动态指针
    InsertTail(&a,CreateStu(1,"zhangsan"));
    InsertTail(&a,CreateStu(2,"lisi"));
    InsertTail(&a,CreateStu(3,"wangwu"));//三个结构体
    

    // for(int i = 0; i < 20; i++)
    // {
    //     InsertTail(&a,i+1);
    // }
    PrintDArray(&a,PrintStu);
    
    return 0;
    //回调函数
}